<template>
    <div class="home-swipe">
        <van-search v-model="search" placeholder="请输入搜索关键词" shape="round" input-align="center" @search="onSearch" @focus="onFocus" />
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="item in bannerData" :key="item.id">
            <!--<img :src="item.picUrl" alt=""-->
            <van-image :src="item.picUrl" lazy-load />
            </van-swipe-item>
        </van-swipe>
    </div>
</template>
<script>
import { Toast } from 'vant';
//import axios from "axios"
export default {
    data() {
        return {
            search: '',
            bannerData: []
        };
    },
    created() {
        this.getBanner();
    },
    methods: {
        onSearch(val) {
            Toast(val);
        },
        onFocus() {
            Toast("搜索框获得焦点");
        },
        getBanner() {
            this.$request('get', "/recommend/banner")
                .then(res => {
                    console.log(res)
                    if (res.result == 100) {
                        this.bannerData = res.data;
                    }
                })
        },
    },
    mounted() {
        //页面已完成渲染，已经知道有哪些网页元素...获取"home-swipe"是可以
        //this.getBanner();
    }
};
</script>
<style scoped>
/*
.my-swipe .van-swipe-item img {
    width: 100%;
} */
</style>